from django.contrib import admin
from apps.resources.models import SubjectInfoModel, LabelInfoModel, QuestionTypeInfoModel, \
    QuestionLevelInfoModel, QuestionInfoModel


# Register your models here.


class SubjectInfoAdmin(admin.ModelAdmin):
    """
    学科信息管理类
    """
    list_display = ['id', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    ordering = ('id',)
    fields = ['id', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_filter = ['id', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    # 外键不能成为搜索字段
    search_fields = ['id', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


class LabelInfoAdmin(admin.ModelAdmin):
    """
    标签信息管理类
    """
    list_display = ['id', 'subject', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json',
                    'created_time']
    ordering = ('id',)
    fields = ['id', 'subject', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_filter = ['id', 'subject', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json',
                   'created_time']
    # 外键不能成为搜索字段
    search_fields = ['id', 'subject', 'name', 'desc', 'creator', 'is_access', 'checker', 'expand_json',
                     'created_time']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


class QuestionTypeInfoAdmin(admin.ModelAdmin):
    """
    问题类型信息管理类
    """
    list_display = ['id', 'type', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    ordering = ('id',)
    fields = ['id', 'type', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_filter = ['id', 'type', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    # 外键不能成为搜索字段
    search_fields = ['id', 'type', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


class QuestionLevelInfoAdmin(admin.ModelAdmin):
    """
    问题类型信息管理类
    """
    list_display = ['id', 'level', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    ordering = ('id',)
    fields = ['id', 'level', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_filter = ['id', 'level', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    # 外键不能成为搜索字段
    search_fields = ['id', 'level', 'name', 'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


class QuestionInfoAdmin(admin.ModelAdmin):
    """
    问题信息管理类
    """
    list_display = ['id', 'subject', 'label', 'type', 'level', 'title', 'options', 'answer', 'analysis',
                    'checker', 'is_access', 'creator', 'expand_json', 'created_time']
    ordering = ('id',)
    fields = ['id', 'subject', 'label', 'type', 'level', 'title', 'options', 'answer', 'analysis',
              'checker', 'is_access', 'creator', 'expand_json', 'created_time']
    list_filter = ['id', 'subject', 'label', 'type', 'level', 'title', 'options', 'answer', 'analysis',
                   'checker', 'is_access', 'creator', 'expand_json', 'created_time']
    # 外键不能成为搜索字段
    search_fields = ['id', 'subject', 'label', 'type', 'level', 'title', 'options', 'answer', 'analysis',
                     'creator', 'is_access', 'checker', 'expand_json', 'created_time']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


admin.site.register(SubjectInfoModel, SubjectInfoAdmin)
admin.site.register(LabelInfoModel, LabelInfoAdmin)
admin.site.register(QuestionTypeInfoModel, QuestionTypeInfoAdmin)
admin.site.register(QuestionLevelInfoModel, QuestionLevelInfoAdmin)
admin.site.register(QuestionInfoModel, QuestionInfoAdmin)
